import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    needLogin: false,
    isLogin: false,
    showMenu: false,
    formData: {},
    routeData: {},
    loginUser: {},
    yqdzTitle: false
  },
  actions: {
    changeLoginState({ commit }, options) {
      commit('setLoginState', options);
    },
    changeNeedLogin({ commit }, options) {
      commit('setNeedLogin', options);
    },
    saveFormData({ commit }, options) {
      commit('setFormData', options);
    },
    saveRoute({ commit }, options) {
      commit('setRouteData', options);
    },
    changeLoginUser({ commit }, options) {
      commit('setLoginUser', options);
    },
    changeYqdzTitle({ commit }, options) {
      commit('setyqdzTitle', options);
    }
  },
  mutations: {
    setLoginState(state, params) {
      state.isLogin = params;
    },
    setNeedLogin(state, params) {
      state.needLogin = params;
    },
    setFormData(state, params) {
      state.formData = params;
    },
    setRouteData(state, params) {
      state.routeData = params;
    },
    setLoginUser(state, params) {
      console.log(params);
      state.loginUser = params;
    },
    setyqdzTitle(state, params) {
      console.log(params);
      state.yqdzTitle = params;
    }
  },
  modules: {}
});
